package com.joyoung.datarespository;

import org.json.JSONObject;

/**
 * Created by Administrator on 2017\8\7 0007.
 */

public class UserMenuBuilder {

    private JSONObject jsonObject = new JSONObject();
    private JSONObject data = new JSONObject();

    private boolean hasData = false;


    public UserMenuBuilder dcode(String dcode) throws Exception {
        data.put("dcode", dcode);
        hasData = true;
        return this;
    }


    public UserMenuBuilder devid(String devid) throws Exception {
        jsonObject.put("devid", devid);
        return this;
    }

    public UserMenuBuilder istype(int istype) throws Exception {
        jsonObject.put("istype", istype);
        return this;
    }

    public UserMenuBuilder jsonstr(String jsonstr) throws Exception {
        jsonObject.put("jsonstr", jsonstr);
        return this;
    }
    public UserMenuBuilder menuid(String menuid) throws Exception {
        jsonObject.put("menuid", menuid);
        return this;
    }
    public UserMenuBuilder mtype(int mtype) throws Exception {
        jsonObject.put("mtype", mtype);
        return this;
    }


    public String build() throws Exception {
        if(hasData){
            jsonObject.put("data", data);
        }
        return jsonObject.toString();
    }
}
